<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <h:outputStylesheet library="css" name="main.css" />
</h:head>
<h:body>
    <h:form>
        <h3>#{msgs.loginHello}: #{usuarioMB.usuario.nome} || <h:commandLink action="#{UsuarioMB.logOut()}" value="Sair" /> </h3>
 
        <h:messages />
        <h:dataTable value="#{estoqueMB.getAllEstoque}" var="estoque" styleClass="table" headerClass="tableColumnsHeader" rowClasses="tableFirstLine,tableNextLine" >
            <h:column>
                <f:facet name="header">
                   Nome
                </f:facet>
                 #{estoque.material.nome}
 
                #{estoque.medicamento.nome}
            </h:column>
            <h:column>
                <f:facet name="header">
                   Quantidade
                </f:facet>
 
                #{estoque.quantidade}
            </h:column>
            <h:column>
                <h:panelGrid columns="2">
                    <!-- Always save the id as hidden when you use a request scope MB -->
                    <h:inputHidden value="#{estoque.id}" />
 
                    <h:commandButton action="#{estoqueMB.updateEstoqueStart()}" value="Atualizar" rendered="#{usuarioMB.userAdmin}" >
                        <f:setPropertyActionListener target="#{estoqueMB.estoque}" value="#{estoque}" />
                    </h:commandButton>
                    <h:commandButton action="#{estoqueMB.deleteEstoqueStart()}" value="delete" rendered="#{userMB.userAdmin}" >
                        <f:setPropertyActionListener target="#{estoqueMB.estoque}" value="#{estoque}" />
                    </h:commandButton>
                </h:panelGrid>
            </h:column>
        </h:dataTable>
        <!-- This button is displayed to the user, just to you see the error msg  -->
        <h:commandButton action="createEstoque" value="Criar estoque" />
    </h:form>
</h:body>
</html>